<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Login_model extends CI_Model
{
    public function __construct() {
        parent::__construct();
        $this->load->database();
    }
    public function checkLogin($email,$password)
    {
        $this->db->where('email',$email);
        $this->db->where('password',md5($password));
        $this->db->from('Role');
        if($this->db->count_all_results()!=0)
        {
        $this->db->where('email',$email);
        $this->db->where('password',md5($password));    
        $query = $this->db->get('Role');
        return $query->result();
        }
        else return 0;
    }
    public function checkOldPassword($email,$oldpass)
    {
        $this->db->where('email',$email);
        $this->db->where('password',md5($oldpass));
        $query=$this->db->get('Role');
        return $query;
    }
    public function changePassword($email,$newpass)
    {
        $change_pass=array('password'=>md5($newpass));
        $changepass=$this->db->update('Role',$change_pass,array('email'=>$email));
        return $changepass;
    }
}
?>
